<?php
/*
 * File name : SigninLogin.php
 * Description : User Authentication and redirection to the Index page.
 * Created By : Pratibha Awasthi
 */

include_once "basePage.php";

class SigninLogin extends basePage{
	
	public function redirect_main(){
		
		$userid = $_POST['userid'];
		$password = $_POST['password'];
		session_start();
		$_SESSION['accessType'] = $_POST['type']; 
		$_SESSION['userid'] = $_POST['userid'];
		
		$con = mysql_connect('localhost','pa_user','secret_password');
			if (!$con){
		  		die('Could not connect: ' . mysql_error());
		  	}
		  
			mysql_select_db("TGS_GM_RESERVATION", $con);
    	    
			$result = mysql_query("SELECT UserID FROM TGS_GM_RESERVATION.tblsubscriber WHERE UserID = '{$userid}' AND UserPassword = '{$password}'");
		 	$row = mysql_fetch_array($result);
		 	
		 	if ($row['UserID'] != NULL){
		 		header("Location: http://localhost/good-mojo-donation/trunk/src/index.php");
		 		
		 	}
		 	else{
		 		echo <<<ESIGNUP
				<form name="SigninLogin" method="post" action="">
				<h3> Please enter correct Login and Password !!! </h3>
				<p>
		           <input type = 'submit' name = 'submit' value = 'Back' onclick='history.go(-1);'>
		        </p>
		
</form>
ESIGNUP;
		 	}
		
	}
}

$page = new SigninLogin();
$page->header();
$page->topmenu_login();
$page->redirect_main();
$page->footer();

?>